package org.example.controller;

import org.example.GetConnection;
import org.example.info.Result;
import org.example.info.loginBody;
import org.example.info.User;
import org.springframework.web.bind.annotation.*;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
//登录
@RestController
@CrossOrigin(origins = "*")
public class UserController {
    private Connection connection = new GetConnection().GetConnection();
    private PreparedStatement statement;
    private ResultSet resultSet;
    private static List<User> userList = new ArrayList<>();

    static {
        userList.add(new User(1, "hwj", 0, "123"));
    }

    @PostMapping("/login")
    public Result<?> login(@RequestBody loginBody body) {
        System.out.println(body.toString());

        return Result.success(userList.get(0));
    }

    //获取用户列表
    @GetMapping("/users")
    public List<User> getUserlist() {
        return userList;
    }

}
